package com.ruoyi.project.hidden.hiddenOrder.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.project.hidden.hiddenRepair.domain.HiddenRepair;
import com.ruoyi.project.hidden.hiddenRepair.mapper.HiddenRepairMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.hidden.hiddenOrder.mapper.HiddenOrderMapper;
import com.ruoyi.project.hidden.hiddenOrder.domain.HiddenOrder;
import com.ruoyi.project.hidden.hiddenOrder.service.IHiddenOrderService;
import com.ruoyi.common.utils.text.Convert;

/**
 * 隐患单据Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-01-23
 */
@Service
public class HiddenOrderServiceImpl implements IHiddenOrderService 
{
    @Autowired
    private HiddenOrderMapper hiddenOrderMapper;

    @Autowired
    private HiddenRepairMapper hiddenRepairMapper;

    /**
     * 查询隐患单据
     * 
     * @param orderId 隐患单据ID
     * @return 隐患单据
     */
    @Override
    public HiddenOrder selectHiddenOrderById(Long orderId)
    {
        return hiddenOrderMapper.selectHiddenOrderById(orderId);
    }

    /**
     * 查询隐患单据列表
     * 
     * @param hiddenOrder 隐患单据
     * @return 隐患单据
     */
    @Override
    public List<HiddenOrder> selectHiddenOrderList(HiddenOrder hiddenOrder)
    {
        return hiddenOrderMapper.selectHiddenOrderList(hiddenOrder);
    }

    /**
     * 新增隐患单据
     * 
     * @param hiddenOrder 隐患单据
     * @return 结果
     */
    @Override
    public int insertHiddenOrder(HiddenOrder hiddenOrder)
    {
        hiddenOrder.setCreateTime(DateUtils.getNowDate());
        return hiddenOrderMapper.insertHiddenOrder(hiddenOrder);
    }

    /**
     * 修改隐患单据
     * 
     * @param hiddenOrder 隐患单据
     * @return 结果
     */
    @Override
    public int updateHiddenOrder(HiddenOrder hiddenOrder)
    {
        hiddenOrder.setUpdateTime(DateUtils.getNowDate());
        return hiddenOrderMapper.updateHiddenOrder(hiddenOrder);
    }

    /**
     * 删除隐患单据对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteHiddenOrderByIds(String ids)
    {
        String[] strings = Convert.toStrArray(ids);
        for (String id : strings) {
            hiddenRepairMapper.deleteSomeByOrderId(id);
        }
        return hiddenOrderMapper.deleteHiddenOrderByIds(strings);
    }

    /**
     * 删除隐患单据信息
     * 
     * @param orderId 隐患单据ID
     * @return 结果
     */
    @Override
    public int deleteHiddenOrderById(Long orderId)
    {
        return hiddenOrderMapper.deleteHiddenOrderById(orderId);
    }

    @Override
    public List<HiddenOrder> queryDispatchList(Long dutyId) {
        return hiddenOrderMapper.queryDispatchList(dutyId);
    }

    @Override
    public Integer queryAuditNum(Long dutyId) {
        return hiddenOrderMapper.queryAuditNum(dutyId);
    }
}
